﻿using PureMVC.Interfaces;
using PureMVC.Patterns.Facade;

namespace CounterApp.PureMVC
{
    public class App : Facade
    {
        public const string KEY = "app";

        public static IFacade Instance
        {
            get
            {
                if (mApp == null)
                {
                    mApp = new App();
                }

                return mApp;
            }
        }

        private static IFacade mApp = null;

        protected App() : base(KEY)
        {
        }

        protected override void InitializeController()
        {
            base.InitializeController();
            
            RegisterCommand(IncreaseCommand.KEY,()=>new IncreaseCommand());
            RegisterCommand(DecreaseCommand.KEY,()=>new DecreaseCommand());
        }

        protected override void InitializeModel()
        {
            base.InitializeModel();
            
            RegisterProxy(new CounterAppModelProxy(new CounterAppModel()));
        }
    }
}